/****************************************************************
 *
 *  Add some comments here
 * 
 * 
 * 
 * 
 ***************************************************************/

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace Wicresoft.OmsClient
{
    class XmlBuilder
    {
        public static string XmlSerializer<T>(T serialObject) where T : class
        {
            XmlSerializer ser = new XmlSerializer(typeof(T));
            System.IO.MemoryStream mem = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(mem, Encoding.Unicode);
            ser.Serialize(writer, serialObject);
            writer.Close();

            return Encoding.Unicode.GetString(mem.ToArray());
        }

        public static T XmlDeserialize<T>(string str) where T : class
        {
            XmlSerializer mySerializer = new XmlSerializer(typeof(T));
            StreamReader mem2 = new StreamReader(
                    new MemoryStream(System.Text.Encoding.Unicode.GetBytes(str)),
                    System.Text.Encoding.Unicode);

            return (T)mySerializer.Deserialize(mem2);
        }
    }
}
